package gui;

import javax.microedition.lcdui.Graphics;

import logic.Point;
/**
 * special kind of button used on all canvases
 * @author Rekin
 *
 */
public class CanvasButton extends CanvasButtonTemplate{

	private String myLabel;
	private boolean selected;
	private boolean enabled;
	
	/**
	 * constructor for button
	 * @param wid button width
	 * @param hei button height
	 * @param p top left Point of the button
	 * @param label label shown on the button
	 */
	public CanvasButton(int wid, int hei, Point p, String label) {
		super(wid, hei,p);
		myLabel=label;
		selected=false;
		enabled=true;
	}
	
	/**
	 * @Override
	 * painting the component on canvas
	 */
	protected void paintMe(Graphics g){
		super.paintMe(g);
		g.setFont(myUsedFont);
		if(selected){
			g.setColor(250, 220, 20);
		}
		if(!enabled){
			g.setColor(128, 128, 128);
		}
		g.drawString(myLabel, myWidth/2+topLeft.getX(), myBaselineOffset+topLeft.getY(), Graphics.BASELINE | Graphics.HCENTER);
	}

	/**
	 * sets button selection
	 * @param selected flag indicating button selection
	 */
	public void setSelected(boolean selected) {
		this.selected = selected;
	}

	/**
	 * checks if button is selected
	 * @return button selected flag
	 */
	public boolean isSelected() {
		return selected;
	}

	/**
	 * sets button label
	 * @param myLabel label for button
	 */
	public void setMyLabel(String myLabel) {
		this.myLabel = myLabel;
	}

	/**
	 * @return enabled
	 */
	public boolean isEnabled() {
		return enabled;
	}

	/**
	 * @param enabled
	 */
	public void setEnabled(boolean enabled) {
		this.enabled = enabled;
	}

}
